package org.example.promptword.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.promptword.Vo.TagVO;
import org.example.promptword.entity.PromptTag;

import java.util.List;

@Mapper
public interface PromptTagMapper extends BaseMapper<PromptTag> {
    // 根据模板ID查询关联的所有未删除标签
    @Select("SELECT t.id as tagId, t.name, t.type, t.color, t.rgb_color as rgbColor " +
            "FROM prompt_tag t " +
            "INNER JOIN prompt_relation_tag rt ON t.id = rt.tag_id " +
            "WHERE rt.template_id = #{templateId} AND t.deleted = 0")
    List<TagVO> findTagsByTemplateId(@Param("templateId") Integer templateId);
}